home *** CD-ROM | disk | FTP | other *** search
- <?xml version='1.0' ?>
- <!-- /*//////////////////////////////////////////////////////////////////////
- //filename: log.xsl
- //copyright(c): Tiny Software corp 2002, 2003 (http://www.tinysoftware.com)
- //author: Jozef Palocko (jpalocko@tinysoftware.com)
- //product: Tiny Personal Firewall 5.x
- //description: Log analyzer stylesheet
- //changelog:
- // 18.8.2003 - added displaying date in local time zone
- ///////////////////////////////////////////////////////////////////////*/ -->
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:msxsl="urn:schemas-microsoft-com:xslt"
- xmlns:time="http://mycompany.com/mynamespace">
-
-
- <xsl:output method="html" indent="yes" />
- <msxsl:script language="JScript" implements-prefix="time">
- <![CDATA[
- function LocalTime(node)
- {
- nd = node.nextNode();
- t = new Date(Date.parse(nd.getAttribute("dateTimeLast")));
- return t.toLocaleString( );
- }
- ]]>
- </msxsl:script>
-
- <xsl:variable name="Def" select="document('../FncIds.xml ')"/>
- <xsl:variable name="Filter" select="document('filter.xml')"/>
-
- <!--
- //////////////////////////////////////
- ///////// Named filter templates
- -->
-
- <!-- ///////// tplModule //////////// -->
-
- <xsl:template name="tplModule" >
- <xsl:param name="Events"/>
- <xsl:choose>
- <xsl:when test='$Filter//module="1"'>
- <xsl:call-template name="tplObject">
- <xsl:with-param name="Events" select='$Events[@module = "Windows Security" ]'/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test='$Filter//module="2"'>
- <xsl:call-template name="tplDirection">
- <xsl:with-param name="Events" select='$Events[@module = "Firewall" ]'/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test='$Filter//module="16"'>
- <xsl:call-template name="tplMessage">
- <xsl:with-param name="Events" select='$Events[@module = "IDS" ]'/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="tplAr">
- <xsl:with-param name="Events" select="$Events"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <!-- ///////// tplObject //////////// -->
-
- <xsl:template name="tplObject" >
- <xsl:param name="Events"/>
- <xsl:choose>
- <xsl:when test="$Filter//string=''">
- <xsl:call-template name="tplAr">
- <xsl:with-param name="Events" select="$Events"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="tplAr">
- <xsl:with-param name="Events" select="$Events[contains(
- translate( Object, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'),
- translate($Filter//string,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>
-
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <!-- ///////// tplMessage //////////// -->
-
- <xsl:template name="tplMessage" >
- <xsl:param name="Events"/>
- <xsl:choose>
- <xsl:when test="$Filter//string=''">
- <xsl:call-template name="tplAr">
- <xsl:with-param name="Events" select="$Events"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="tplAr">
- <xsl:with-param name="Events" select="$Events[contains(
- translate( Msg, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'),
- translate($Filter//string,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>
-
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
-
- <!-- ///////// tplDirection //////////// -->
- <xsl:template name="tplDirection" >
- <xsl:param name="Events"/>
- <xsl:choose>
- <xsl:when test="$Filter//direction=''">
- <xsl:call-template name="tplProtocol">
- <xsl:with-param name="Events" select="$Events"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="tplProtocol">
- <xsl:with-param name="Events" select="$Events[InetDef/@dir = $Filter//direction]"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- ///////// tplProtocol //////////// -->
- <xsl:template name="tplProtocol" >
- <xsl:param name="Events"/>
- <xsl:choose>
- <xsl:when test="$Filter//protocol=''">
- <xsl:call-template name="tplIPAddress">
- <xsl:with-param name="Events" select="$Events"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="tplIPAddress">
- <xsl:with-param name="Events" select="$Events[contains(InetDef/@prot , $Filter//protocol)]"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- ///////// tplIPAddress //////////// -->
- <xsl:template name="tplIPAddress" >
- <xsl:param name="Events"/>
- <xsl:choose>
- <xsl:when test="$Filter//ip=''">
- <xsl:call-template name="tplRemPort">
- <xsl:with-param name="Events" select="$Events"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="tplRemPort">
- <xsl:with-param name="Events" select="$Events[contains(
- translate( InetDef/@remIp, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'),
- translate($Filter//ip,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!-- ///////// tplRemPort //////////// -->
-
- <xsl:template name="tplRemPort" >
- <xsl:param name="Events"/>
- <xsl:choose>
- <xsl:when test="$Filter//remport=''">
- <xsl:call-template name="tplLocPort">
- <xsl:with-param name="Events" select="$Events"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="tplLocPort">
- <xsl:with-param name="Events" select="$Events[InetDef/@remPort = $Filter//remport]"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <!-- ///////// tplLocPort //////////// -->
-
- <xsl:template name="tplLocPort" >
- <xsl:param name="Events"/>
- <xsl:choose>
- <xsl:when test="$Filter//locport=''">
- <xsl:call-template name="tplAr">
- <xsl:with-param name="Events" select="$Events"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="tplAr">
- <xsl:with-param name="Events" select="$Events[InetDef/@locPort = $Filter//locport]"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <!-- ///////// tpl access result //////////// -->
- <xsl:template name="tplAr" >
- <xsl:param name="Events"/>
- <xsl:choose>
- <xsl:when test="$Filter//ar=''">
- <xsl:call-template name="tplApplication">
- <xsl:with-param name="Events" select="$Events"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="tplApplication">
- <xsl:with-param name="Events" select="$Events[Action = $Filter//ar]"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <!-- ///////// tplApplication result //////////// -->
-
- <xsl:template name="tplApplication" >
- <xsl:param name="Events"/>
- <xsl:choose>
- <xsl:when test="$Filter//app=''">
- <xsl:call-template name="tplUser">
- <xsl:with-param name="Events" select="$Events"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="tplUser">
- <xsl:with-param name="Events" select="$Events[contains(
- translate( App, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'),
- translate($Filter//app,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <!-- ///////// tplUser result //////////// -->
-
- <xsl:template name="tplUser" >
- <xsl:param name="Events"/>
- <xsl:choose>
- <xsl:when test="$Filter//user=''">
- <!-- should never occur -->
- <xsl:call-template name="tplDomain">
- <xsl:with-param name="Events" select="$Events"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="$Filter//user='All Users (*)'">
- <xsl:choose>
- <xsl:when test="$Filter//sort='App'">
- <xsl:apply-templates select='$Events[ not(@module="IDS") and not(App=preceding-sibling::Event/App) or
- not(@module=preceding-sibling::Event/@module) or
- not(count(@user)=0) and not(@user=preceding-sibling::Event/@user) or
- not(count(@domain)=0) and not(@domain=preceding-sibling::Event/@domain) or
- @module="IDS" and not(Msg=preceding-sibling::Event/Msg) or
- not(Action=preceding-sibling::Event/Action) or
- @module="Firewall" and not (
- InetDef/@prot=preceding-sibling::Event/InetDef/@prot and
- (count(InetDef/@dir)=0 or InetDef/@dir=preceding-sibling::Event/InetDef/@dir) and
- (count(InetDef/@remPort)=0 or InetDef/@remPort=preceding-sibling::Event/InetDef/@remPort) and
- (count(InetDef/@remIp)=0 or InetDef/@remIp=preceding-sibling::Event/InetDef/@remIp)
- )
- ]'>
- <xsl:with-param name="Total" select="count($Events)"/>
- <xsl:with-param name="Events" select="$Events"/>
-
- <xsl:sort select="App" order="ascending"/>
- <xsl:sort select="@module" order="ascending"/>
- <xsl:sort select="@user" order="ascending"/>
- <xsl:sort select="@domain" order="ascending"/>
- <xsl:sort select="Object" order="ascending"/>
- <xsl:sort select="Msg" order="ascending"/>
- <xsl:sort select="Action" order="ascending"/>
- <xsl:sort select="InetDef/@dir" order="ascending"/>
- <xsl:sort select="InetDef/@remIp" order="ascending"/>
- <xsl:sort select="InetDef/@LocIp" order="ascending"/>
-
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="$Events">
- <xsl:with-param name="Total" select="count($Events)"/>
-
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="tplDomain">
- <xsl:with-param name="Events" select="$Events[@module='IDS' or contains(
- translate( @user, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'),
- translate($Filter//user,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <!-- ///////// tplDomain result //////////// -->
-
- <xsl:template name="tplDomain" >
- <xsl:param name="Events"/>
- <xsl:variable name="EventsSortedByApp" select="$Events[ not(@module='IDS') and not(App=preceding-sibling::Event/App) or
- not(@module=preceding-sibling::Event/@module) or
- not(count(@domain)=0) and not(@domain=preceding-sibling::Event/@domain) or
- @module='IDS' and not(Msg=preceding-sibling::Event/Msg) or
- not(Action/@ar=preceding-sibling::Event/Action/@ar) or
- @module='Firewall' and not (
- InetDef/@prot=preceding-sibling::Event/InetDef/@prot and
- (count(InetDef/@dir)=0 or InetDef/@dir=preceding-sibling::Event/InetDef/@dir) and
- (count(InetDef/@remPort)=0 or InetDef/@remPort=preceding-sibling::Event/InetDef/@remPort) and
- (count(InetDef/@remIp)=0 or InetDef/@remIp=preceding-sibling::Event/InetDef/@remIp)
- )
- ]"/>
- <xsl:choose>
- <xsl:when test="$Filter//domain=''">
- <!-- domain filter is empty -->
- <xsl:choose>
- <xsl:when test="$Filter//sort='App'">
- <xsl:apply-templates select="$EventsSortedByApp">
- <xsl:with-param name="Total" select="count($Events)"/>
-
- <xsl:sort select="App" order="ascending"/>
- <xsl:sort select="@domain" order="ascending"/>
- <xsl:sort select="@module" order="ascending"/>
- <xsl:sort select="Object" order="ascending"/>
- <xsl:sort select="Msg" order="ascending"/>
- <xsl:sort select="Action" order="ascending"/>
- <xsl:sort select="InetDef/@dir" order="ascending"/>
- <xsl:sort select="InetDef/@remIp" order="ascending"/>
- <xsl:sort select="InetDef/@LocIp" order="ascending"/>
-
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="$Events">
- <xsl:with-param name="Total" select="count($Events)"/>
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <!-- domain filter is not empty -->
- <xsl:choose>
- <xsl:when test="$Filter//sort='App'">
- <xsl:variable name="selected_events" select="$EventsSortedByApp[contains(
- translate( @domain, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'),
- translate($Filter//domain,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>
- <xsl:apply-templates select="$selected_events">
- <xsl:with-param name="Total" select="count($selected_events)"/>
- <!-- count all events from this user and domain, not sorted by app -->
- <xsl:with-param name="Events" select="$Events[contains(
- translate( @domain, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'),
- translate($Filter//domain,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>
- <xsl:sort select="App" order="ascending"/>
- <xsl:sort select="@domain" order="ascending"/>
- <xsl:sort select="@module" order="ascending"/>
- <xsl:sort select="Object" order="ascending"/>
- <xsl:sort select="Msg" order="ascending"/>
- <xsl:sort select="Action" order="ascending"/>
- <xsl:sort select="InetDef/@dir" order="ascending"/>
- <xsl:sort select="InetDef/@remIp" order="ascending"/>
- <xsl:sort select="InetDef/@LocIp" order="ascending"/>
-
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="selected_events" select="$Events[ @module='IDS' or contains(
- translate( @domain, '_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' , '_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'),
- translate($Filter//domain,'_-\/.:;,ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','_-\/.:;,abcdefghijklmnopqrstuvwxyz0123456789'))]"/>
- <xsl:apply-templates select="$selected_events">
- <xsl:with-param name="Total" select="count($selected_events)"/>
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
-
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- </xsl:stylesheet>
-